/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cl.bussines.entities;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Vogel
 */
@Entity
@Table(name = "provincias")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Provincias.findAll", query = "SELECT p FROM Provincias p"),
    @NamedQuery(name = "Provincias.findByCUTProvincia", query = "SELECT p FROM Provincias p WHERE p.cUTProvincia = :cUTProvincia"),
    @NamedQuery(name = "Provincias.findByNomProvincia", query = "SELECT p FROM Provincias p WHERE p.nomProvincia = :nomProvincia"),
    @NamedQuery(name = "Provincias.findByCapitalProvincial", query = "SELECT p FROM Provincias p WHERE p.capitalProvincial = :capitalProvincial")})
public class Provincias implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "CUT_Provincia")
    private Integer cUTProvincia;
    @Size(max = 80)
    @Column(name = "Nom_Provincia")
    private String nomProvincia;
    @Size(max = 45)
    @Column(name = "Capital_Provincial")
    private String capitalProvincial;
    @JoinColumn(name = "CUT_Region", referencedColumnName = "CUT_Region")
    @ManyToOne(optional = false)
    private Regiones cUTRegion;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "cUTProvincia")
    private Collection<Comunas> comunasCollection;

    public Provincias() {
    }

    public Provincias(Integer cUTProvincia) {
        this.cUTProvincia = cUTProvincia;
    }

    public Integer getCUTProvincia() {
        return cUTProvincia;
    }

    public void setCUTProvincia(Integer cUTProvincia) {
        this.cUTProvincia = cUTProvincia;
    }

    public String getNomProvincia() {
        return nomProvincia;
    }

    public void setNomProvincia(String nomProvincia) {
        this.nomProvincia = nomProvincia;
    }

    public String getCapitalProvincial() {
        return capitalProvincial;
    }

    public void setCapitalProvincial(String capitalProvincial) {
        this.capitalProvincial = capitalProvincial;
    }

    public Regiones getCUTRegion() {
        return cUTRegion;
    }

    public void setCUTRegion(Regiones cUTRegion) {
        this.cUTRegion = cUTRegion;
    }

    @XmlTransient
    public Collection<Comunas> getComunasCollection() {
        return comunasCollection;
    }

    public void setComunasCollection(Collection<Comunas> comunasCollection) {
        this.comunasCollection = comunasCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (cUTProvincia != null ? cUTProvincia.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Provincias)) {
            return false;
        }
        Provincias other = (Provincias) object;
        if ((this.cUTProvincia == null && other.cUTProvincia != null) || (this.cUTProvincia != null && !this.cUTProvincia.equals(other.cUTProvincia))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "cl.bussines.entities.Provincias[ cUTProvincia=" + cUTProvincia + " ]";
    }
    
}
